package nf.com.crud.controller;

import nf.com.crud.entity.Test2;
import nf.com.crud.service.Test2Service;
import nf.com.crud.service.impl.Test2ServiceImpl;
import nf.com.crud.utils.JsonUtils;
import nf.com.crud.vo.ResponseVo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/list")
public class Test2ListController extends HttpServlet {
    Test2Service test2Service=new Test2ServiceImpl();

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("application/json;charset=UTF-8");

        List<Test2> list=test2Service.getAll();

        ResponseVo responseVo=new ResponseVo(200,"成功",list);
        String s= JsonUtils.write(responseVo);
        resp.getWriter().println(s);
    }
}
